//
//  ReadRankViewController.m
//  iread
//
//  Created by 朱经扬 on 15/12/16.
//  Copyright © 2015年 朱经扬. All rights reserved.
//

#import "ReadRankViewController.h"
#import "ReadRankCollectionViewCell.h"

@interface ReadRankViewController ()
// 名称数组
@property (nonatomic ,copy)NSArray *nameArr;
// 图片数组
@property (nonatomic ,copy)NSArray *ImageArr;
@end

@implementation ReadRankViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.nameArr = @[@"我的知识",@"排行列表",@"我的学科",@"我的排行"];
    self.ImageArr = @[@"knowledge",@"ranking",@"subject",@"myranking"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 4;
}

-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    return 1;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identify = @"rankCell";
    ReadRankCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identify forIndexPath:indexPath];
    
    //加载图片和名称
    cell.rankNameLabel.text = [self.nameArr objectAtIndex:indexPath.row];
    [cell.bookBtn setBackgroundImage:[UIImage imageNamed:[self.ImageArr objectAtIndex:indexPath.row]] forState:UIControlStateNormal];
    
    return cell;
}

// 设置cell的宽高
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake(SCREEN_PX*90,SCREEN_PX*150);
}

//定义每个UICollectionView 的 margin
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
    return UIEdgeInsetsMake(SCREEN_PX*5,SCREEN_PX*13, SCREEN_PX*5, SCREEN_PX*13);
}
@end
